#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_E = 20 + 10;
const int MAX_N = 1000 + 10;

int dp[MAX_E][MAX_N];


int main() {
	int e, n;

	e = 20;
	n = 1000;
	for (int j = 0; j <= n; ++j) {
		dp[1][j] = j;
	}
	for (int i = 2; i <= e; ++i) {
			for (int j = 1; j <= n; ++j) {
				int min_value = max(dp[i - 1][0], dp[i][j - 1]);
				for (int k = 2; k <= j; ++k) {
					min_value = min(min_value,
						max(dp[i - 1][k - 1], dp[i][j - k]));
				}
				dp[i][j] = min_value + 1;
			}
	}
	while (scanf("%d%d", &e, &n) && (e != 0 && n != 0)) {
		int max_e = 1;
		while ((1 << max_e) < (n + 1)) {
			++max_e;
		}
		if (e > max_e) {
			e = max_e;
		}
		printf("%d\n", dp[e][n]);
	}
	return 0;
}
